﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;

namespace Oridea.Data.Fetching.Tests {
	public class MockCollection<T> : IList<T> {
		private readonly List<T> _list = new List<T>();

		public bool HasCalledCount { get; set; }
		public bool HasCalledGetEnumerator { get; set; }

		public int IndexOf(T item) {
			return _list.IndexOf(item);
		}

		public void Insert(int index, T item) {
			_list.Insert(index, item);
		}

		public void RemoveAt(int index) {
			_list.RemoveAt(index);
		}

		public T this[int index] {
			get {
				return _list[index];
			}
			set {
				_list[index] = value;
			}
		}

		public void Add(T item) {
			_list.Add(item);
		}

		public void Clear() {
			_list.Clear();
		}

		public bool Contains(T item) {
			return _list.Contains(item);
		}

		public void CopyTo(T[] array, int arrayIndex) {
			_list.CopyTo(array, arrayIndex);
		}

		public int Count {
			get {
				HasCalledCount = true;
				return _list.Count;
			}
		}

		public bool IsReadOnly {
			get { return ((ICollection<T>)_list).IsReadOnly; }
		}

		public bool Remove(T item) {
			return _list.Remove(item);
		}

		public IEnumerator<T> GetEnumerator() {
			HasCalledGetEnumerator = true;
			return _list.GetEnumerator();
		}
		
		System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() {
			HasCalledGetEnumerator = true;
			return _list.GetEnumerator();
		}
	}
}
